<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // function fn({x,y = 5}){
        //     console.log(x,y);
        // }    
        // fn({x:10})//10,5

        // fn();//报错//传的是undefined，但是上面的形参必须要接收一个对象


        // // function fn1(obj = {})
        // function fn({x,y = 5} = {}){
        //     console.log(x,y);
        // }    

        // // {x,y = 5} = {x:10}
        // fn({x:10})//10,5

        // // {x,y = 5} = {}
        // fn();//undefined 5

        // 写法1
        function m1({ x = 0,y = 0 } = {}){
            return [x,y];
        }

        // 写法1
        function m2({ x,y } = { x:0,y:0 }){
            return [x,y];
        }

        console.log(m1());//[0,0]
        console.log(m2());//[0,0]

        console.log(m1({x:99}));//[99,0]
        console.log(m2({x:99}));//[99,undefined]

    </script>
</body>
</html>